<!-- 
    
 -->
<html>

<head>
    <title>Canvas tutorial</title>
    <script type="text/javascript">
        function onload() {
            var ctx = document.getElementById('canvas').getContext('2d');
            var offset = 0;

            function draw() {
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.setLineDash([4, 2]);
                ctx.lineDashOffset = -offset;
                ctx.strokeRect(10, 10, 100, 100);
            }

            function march() {
                offset++;
                if (offset > 16) {
                    offset = 0;
                }
                draw();
                setTimeout(march, 20);
            }

            march();
        }

    </script>
    <style type="text/css">
        canvas {
            border: 1px solid black;
        }
    </style>
</head>

<body onload="onload();">
    <canvas id="canvas" width="500" height="500"></canvas>
</body>

</html>